//
//  ViewController.m
//  10510登录界面Login
//
//  Created by student on 16/2/20.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIActionSheetDelegate,UIAlertViewDelegate>
@property (weak, nonatomic) IBOutlet UITextField *textField1;
@property (weak, nonatomic) IBOutlet UITextField *textField2;
@property (weak, nonatomic) IBOutlet UITextField *textField3;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)tapBack:(id)sender {
    [self.view endEditing:YES];
}
- (IBAction)btnPressed:(id)sender {
    if ([self.textField1.text isEqualToString:@"admin"]&&[self.textField2.text isEqualToString:@"123456"]) {
        UIActionSheet *sheet=[[UIActionSheet alloc]initWithTitle:@"登录成功,确定保存用户信息吗" delegate:self cancelButtonTitle:@"不保存" destructiveButtonTitle:@"保存" otherButtonTitles: nil];
        [sheet showInView:self.view];

    }
    else if (![self.textField1.text isEqualToString:@"admin"]){
                UIAlertView *alertView =[[UIAlertView alloc]initWithTitle:@"登录失败" message:@"用户名错误,请重新输入" delegate:self cancelButtonTitle: @"确定"otherButtonTitles:nil];
        [alertView show];
    }
    else if (![self.textField2.text isEqualToString:@"123456"]){
        UIAlertView *alertView =[[UIAlertView alloc]initWithTitle:@"登录失败" message:@"密码错误,请重新输入" delegate:self cancelButtonTitle: @"确定"otherButtonTitles:nil];
        [alertView show];
    }
    else  {
        UIAlertView *alertView =[[UIAlertView alloc]initWithTitle:@"登录失败" message:@"登录错误,请重新输入" delegate:self cancelButtonTitle: @"确定"otherButtonTitles:nil];
        [alertView show];
    }
    
}


@end
